<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">
		<link rel="stylesheet" type="text/css" href="" />
		<link rel="stylesheet" href="css/bootstrap.min.css" />
		<script src="javascript/jquery.js" type="text/javascript" charset="utf-8"></script>
		<script src="javascript/bootstrap.min.js" type="text/javascript" charset="utf-8"></script>
		<title>index</title>
		<style type="text/css">
			body {
				margin: 0;
				padding: 0;
			}
			
			.div1 {
				width: 960px;
				display: block;
				background-color: #E5E5E5;
			}
			
			h2 {
				margin: 5px;
				padding: 3px;
			}
			
			.menu-left {
				background-color: lightskyblue;
				padding: 0;
			}
			
			.menu-left>a {
				display: block;
				text-decoration: none;
				text-align: center;
				font-size: 24px;
				cursor: pointer;
				background-color: #E3E3E3;
				width: 100%;
				padding: 5px;
				background-image: -webkit-linear-gradient(#ffffff 50%, #c0c0c0);
				background-image: -moz-linear-gradient(#ffffff 50%, #c0c0c0);
				background-image: -o-linear-gradient(#ffffff 50%, #c0c0c0);
				background-image: -webkit-gradient(linear, 0 0, 0 100%, color-stop(0.5, #ffffff), to(#c0c0c0));
				background-image: linear-gradient(#ffffff 50%, #c0c0c0);
			}
			
			.user-add {
				margin-left: 200px;
			}
		</style>
	</head>

	<body>
		<<div class="div1 center-block">
			<div class="container">
				<div class="row" style="background-color: #C4E3F3; width: 960px;">
					<img src="img/login.png" class="col-lg-2" style="width: 60px; margin-top: 10px;" />
					<h2 class="col-lg-6">学生信息管理信息系统</h2>
					<h4 class="col-lg-4">ByHXZY</h4>
				</div>
				<div class="row content">
					<div class="col-lg-2 menu-left">
						<a id="addstu">添加学生</a>
						<a id="addcou">添加课程</a>
						<a id="manager">综合管理</a>
					</div>
					<div class="col-lg-10">
						<p id="p1" style="height: 400px;"></p>
					</div>
				</div>
				<div class="row">
					<div class="col-lg-12" style="background-color: cadetblue; width: 960px;">
						<p>关于我们</p>
					</div>
				</div>
			</div>
			</div>
			<script type="text/javascript">
				jQuery(document).ready(function() {
					$("#addstu").click(function() {
						$("#p1").load("addstudent.html .user-add", "", function() {
							$("#submitbtn1").click(function() {
								$.ajax({
									type: "post",
									url: "AddStudent",
									async: true,
									data: $("#submit1").serialize(),
									success: function() {
										alert("学生信息添加成功！");
										$("#resetform1").click();
									}
								});
							});
						});
					});
					$("#addcou").click(function() {
						$("#p1").load("addcourse.html .user-add", "", function() {
							$("#submitbtn2").click(function() {
								$.ajax({
									type: "post",
									url: "AddCourse",
									async: true,
									data: $("#submit2").serialize(),
									success: function() {
										alert("课程信息添加成功！");
										$("#resetform2").click();
									}
								});
							});
						});
					});
					$("#manager").click(function() {
						$("#p1").load("editor.html", "", function() {
							$.ajax({
								type: "post",
								url: "Manager",
								dataType: "json",
								success: function(data) {
									//									alert(data);									
									//var obj = $.parseJSON(data);
									var course;								
									$.each(data, function(name, value) {
										$.each(value, function(index, ele) {
											var s = "";
											var row = ele;
											var sid=ele.sid;
											var did=ele.did;
											s = s + "<tr>";
											$.each(ele, function(k, v) {
												if (k == "sid") {
													$("#sid").val(v);
												} else if (k == "did") {
													$("#did").val(v);
												} else {
													s = s + "<td>" + v + "</td>"
												}
											});										
											s = s +"<td class='crname' id='select" + index + "'>" +"</td>" +"<td>" +"<input type='text' value='' id='cscore"+index+"' name='cscore'/>"+"</td>" +
											"<td>" + "<button class='xg'  id='row" + index + "' >保存</button>" + "</td>" + "</tr>";											
											$("#edit").append(s);
											$("#row"+index).click(function () {
												var i=index;
												var cname=$("#select"+i).children().val();
												var cscore=$("#cscore"+i).val();
												$.ajax({
													type:"post",
													url:"ProcessData",
													data:"sid="+sid+"&cname="+cname+"&cscore="+cscore,
													success:function () {
														alert("已获得学生信息");
													}
												});
											});
										});
									});
										$.ajax({
										type: "post",
										url: "GetCourse",
										dataType: "json",
										success: function(data) {
											var str="<select name='select' class='sel'>";
											$.each(data, function(index,element) {
												str=str+"<option value='"+element.name+"'>"+element.name+"</option>";
											});
											str=str+"</select>";
											alert(str);
											$(".crname").html(str);
										}
									});
								}
							});
						});
					});
				});
			</script>
	</body>

</html>